package com.atguigu.ronglianyun.sms.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "ronglianyun.sms")
public class SmsProperties implements BeanPostProcessor {
    private String serverIp;
    private String serverPort;
    private String accountSid;
    private String accountToken;
    private String appId;
    private String templateCode;

    public static String SERVER_IP;
    public static String SERVER_PORT;
    public static String ACCOUNT_SID;
    public static String ACCOUNT_TOKEN;
    public static String APP_ID;
    public static String TEMPLATE_CODE;


    public String getServerIp() {
        return serverIp;
    }

    public void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }

    public String getServerPort() {
        return serverPort;
    }

    public void setServerPort(String serverPort) {
        this.serverPort = serverPort;
    }

    public String getAccountSid() {
        return accountSid;
    }

    public void setAccountSid(String accountSid) {
        this.accountSid = accountSid;
    }

    public String getTemplateCode() {
        return templateCode;
    }

    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }

    public String getAccountToken() {
        return accountToken;
    }

    public void setAccountToken(String accountToken) {
        this.accountToken = accountToken;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        SERVER_IP = serverIp;
        SERVER_PORT = serverPort;
        ACCOUNT_SID = accountSid;
        ACCOUNT_TOKEN = accountToken;
        APP_ID = appId;
        TEMPLATE_CODE = templateCode;
        return bean;
    }
}
